package com.gf.pokemon.dto;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.log4j.Logger;

/**
 * 投票统计
 * @author yesi
 *
 */
public class VoteUserStaticsDto {
	
	private Logger logger = Logger.getLogger(VoteUserStaticsDto.class);
	
	/**
	 * 投票人数
	 */
	private Integer voteNum = 0 ;
	
	/**
	 * 投票标题
	 */
	private String voteTitle = "";
	
	/**
	 * 投票方式
	 */
	private Integer vmode = 0;
	
	/**
	 * 投票选项数
	 */
	private Integer optionNum = 0;
	
	/**
	 * 投票选项总数
	 */
	private Integer voteTotalNum = 0;
	
	/**
	 * 选项的统计
	 */
	private List<VoteUserOptionStaticsDto> optionStatics = 
			new ArrayList<VoteUserOptionStaticsDto>();

	private Map<Integer, VoteUserOptionStaticsDto> optionStaticsMap = 
			new HashMap<Integer, VoteUserOptionStaticsDto>();
	
	public void addVoteNum(Integer num){
		voteNum += num;
	}
	
	public void addVoteTotalNum(Integer num){
		voteTotalNum += num;
	}
	
	public Integer getVoteNum() {
		return voteNum;
	}

	public void setVoteNum(Integer voteNum) {
		this.voteNum = voteNum;
	}
	
	public void addStaticsOption(Integer optionId,String optionName,Integer memoNum){
		VoteUserOptionStaticsDto dto = optionStaticsMap.get(optionId);
		if(dto==null){
			dto = new VoteUserOptionStaticsDto();
		}
		dto.setOptionId(optionId);
		dto.setShowName(optionName);
		dto.addStaticsNum(1);
		dto.addMemo(memoNum);
		optionStaticsMap.put(optionId, dto);
	}
	
	public void sortStaticsOption(){
		if(optionStaticsMap.size()>0){
			optionStatics.addAll(optionStaticsMap.values());
			Collections.sort(optionStatics);
		}
	}

	public List<VoteUserOptionStaticsDto> getOptionStatics() {
		return optionStatics;
	}

	public void setOptionStatics(List<VoteUserOptionStaticsDto> optionStatics) {
		this.optionStatics = optionStatics;
	}

	public String getVoteTitle() {
		return voteTitle;
	}

	public void setVoteTitle(String voteTitle) {
		this.voteTitle = voteTitle;
	}

	public Integer getVmode() {
		return vmode;
	}

	public void setVmode(Integer vmode) {
		this.vmode = vmode;
	}

	public Integer getOptionNum() {
		return optionNum;
	}

	public void setOptionNum(Integer optionNum) {
		this.optionNum = optionNum;
	}

	public Integer getVoteTotalNum() {
		return voteTotalNum;
	}

	public void setVoteTotalNum(Integer voteTotalNum) {
		this.voteTotalNum = voteTotalNum;
	}
	
}

	

